package com.test.controller;

import com.test.config.DynamicDataSource;
import com.test.entity.Tenant;
import com.test.service.TenantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/tenants")
@DynamicDataSource("master")
public class TenantController {

    @Autowired
    private TenantService tenantService;

    @PostMapping
    public Tenant createTenant(@RequestBody Tenant tenant) {
        return tenantService.createTenant(tenant);
    }

    @GetMapping("/{tenantCode}")
    public Tenant getTenant(@PathVariable String tenantCode) {
        return tenantService.getTenantByCode(tenantCode);
    }
} 